
(function () {
  window.onload = (function () {
    var $bignav = $(document).find('#toolkit').length > 0 ? $(document).find('#toolkit') : $(document).find('[data-temp="toolkit"]')
    if ($bignav.length > 0 && $(document).find('[data-postion]').length > 0) {
      var parentTop = $(document).find('[data-postion]').offset().top
      $bignav.css({
        position: 'fixed',
        right: '0.5rem',
        top: parentTop,
        transform: '',
      })
    }
  })

  window.onscroll = function () {
    var topScroll = document.documentElement.scrollTop;//滚动的距离,距离顶部的距离
    var $bignav = $('#toolkit')//获取到导航栏id
    if ($bignav.length == 0) {
      return;
    }
    var parentTop = $(document).find('[data-postion]').offset().top

    if (topScroll <= parentTop) {
      $bignav.css({
        position: 'fixed',
        top: parentTop - topScroll,
        transform: '',
      })
    } else {
      $bignav.css({
        position: 'fixed',
        // top: '50%',
        // transform: 'translateY(-50%)',
      })
    }
  }


})();